<!DOCTYPE html>
<html>
<head>
	<title></title>
	<style type="text/css">
		canvas{
			border: 1px solid #333;
		}
	</style>
</head>
<body>
	<canvas width="600" height="400" id="canvas"></canvas>
	<script type="text/javascript">
		//相当于拿到一张纸
		var canvas=document.getElementById("canvas");
		//获取画笔
		var ctx=canvas.getContext("2d");

		//抬起画笔，把画笔落在(100,100)位置
		ctx.moveTo(100,100)
		ctx.lineTo(200,200)
		ctx.strokeStyle="red";
		ctx.lineWidth="3"
		ctx.stroke()


		//绘制绿色线段
		ctx.beginPath()		//新起一条路径，和原来的路径不干扰
		ctx.strokeStyle="green";
		ctx.moveTo(100,100)
		ctx.lineTo(100,200)
		ctx.stroke()





	
	</script>
</body>
</html>